/*
 * EventLoopThreadPool.h
 *  one loop per thread
 *  Created on: 2021年4月6日
 *      Author: san
 */

#ifndef EVENTLOOPTHREADPOOL_H_
#define EVENTLOOPTHREADPOOL_H_

#include <memory>
#include <vector>
#include "EventLoopThread.h"
#include "base/Logging.h"
#include "base/noncopyable.h"

namespace san {

class EventLoopThreadPool : noncopyable{
public:
	EventLoopThreadPool(EventLoop *baseLoop, int numThreads);
	~EventLoopThreadPool() { LOG << "~EventLoopThreadPool()"; };

	void start();

	EventLoop *getNextLoop();

private:
	EventLoop* baseLoop_;
	bool started_;
	int numThreads_;
	int next_;
	std::vector<std::shared_ptr<EventLoopThread>> threads_;
	std::vector<EventLoop*> loops_;     // 线程池，保存线程
};

} /* namespace san */

#endif /* EVENTLOOPTHREADPOOL_H_ */
